package com.clock.common.config;

import com.alipay.easysdk.factory.Factory;
import com.alipay.easysdk.kernel.Config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;

@Data
@Component
@ConfigurationProperties(prefix = "alipay")
public class F2FPayConfig {
    private String appId = "9021000141628767";
    private String appPrivateKey = "MIIEowIBAAKCAQEAgeRmEI97uImqZxQgbmNz4vmMwoxQLF1rcnNLm00EZwJNnigNJlFry/XsD622JWYDJjM0ueBJH1wMbLiX7k90TqB7fwUPjtlSyivqA98FRfmxx3FodlNhH5PeMJKN9rFBBPgAoV6jyHw9oMgrKJ/q64J/swxr6KKMNzGC/LJywxaJEOEVaG5vlgLAJOycw8kGDlBM8HFQzvAcUqd67jLe5u78VdmRAQZ4BladPr4mBgnTSvu5NwDyIYkxSJxxx7qpegd3YZ3N5PnVGW3guYP2DsRkUyJeHUfpQsVh6nqx67csn4scMICb935rKzHslfYDjbbwkrBlYnr9iyULzynSowIDAQABAoIBAHltXQTKPayr9YLbS94mVuWuyKnupdxzkMizg9Cw1Ra/DnR1mKVjpFRNl9qoWAjqLrN9VyMUywbn9C2G+3ErEd2XJRv/TSYLf9vD5casrK9X15xNJozHMZplj2b0+oXN+qx8c4pngNEhZDN0LPSTWvfDTUHCsPYPTukh/gPhhmtcv3kQaem+38nPsTSid56l+LDce38wNY9zTEsfQmoVM4za6qnEnaRF46hYifSXhcIDOgTr14keCkpRmlTjCZEsXP9zDtKOa3sX6Xn7Q25YZXUjdiqZxmycRwOtE17k8J/9bILNvtnauw9DDPaCktB/EXqulFBVR6O3HWlWQ7oZemECgYEA4IXy1u3d/0p/0bEIQCeg9CqauYXqKYUXbHOcDWjWrWF3/YD/kUubl3Ir09yFwOEg54GzW5tmPgv+xJ9chEIBU/lS35tiWiEnXECHIQUkTp6FBmAWB2dZQl3IKrDzohGf93M7B6aJJBqWJ5HXwlFUJ2i0aEpr9X8a3Ttdgk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UK1SxmVjD7zeaU3B11cPOOdpyBtowIDAQAB";
    private String notifyUrl = "http://ksgz3t.natappfree.cc/alipay/notify";
    @PostConstruct
    public void init() {
        // 设置参数（全局只需设置一次）
        Config options = getOptions();
//        options.appId = aliPayConfig.getAppId();
//        options.merchantPrivateKey = aliPayConfig.getAppPrivateKey();
//        options.alipayPublicKey = aliPayConfig.getAlipayPublicKey();
//        options.notifyUrl = aliPayConfig.getNotifyUrl();
          options.appId = this.appId;
          options.merchantPrivateKey = this.appPrivateKey;
          options.alipayPublicKey = this.alipayPublicKey;
          options.notifyUrl = this.notifyUrl;

        Factory.setOptions(options);
        System.out.println("=======支付宝SDK初始化成功=======");
    }

    private Config getOptions() {
        Config config = new Config();
        config.protocol = "https";
        config.gatewayHost = "openapi.alipaydev.com";
        config.signType = "RSA2";
        return config;
    }
}
